//
//  HomeViewController.swift
//  HeadlineNews
//
//  Created by han on 2019/5/30.
//  Copyright © 2019 han. All rights reserved.
//

import UIKit

class HomeViewController: UIViewController {

    //用于自定义present/dismiss转场动画
    let transition = PresentDelegate()
    
    @IBOutlet weak var imageView: UIImageView!
    @IBOutlet weak var mainLabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.transitioningDelegate = transition
        self.hideNavigationBarIfNeeded = false
        
//        mainLabel.theme.backgroundColor = ThemeConfiguration.mainColor
         mainLabel.theme.backgroundColor = "colors.titleColor"
        imageView.theme.image = "images.home_image"
        print(NSLocalizedString("displayTheme", comment: ""))
        
    }
    @IBAction func buttonAction(_ sender: UIButton) {
//        let list =  NewsListViewController()
////        list.transitionType = .push(.fromRight)
//        self.navigationController?.pushViewController(list, animated: true)
//        print(mainLabel.font.fontName)
//        sender.titleLabel?.font = UIFont.systemFont(ofSize: 12)
//        let list =  NewsListViewController()
//        list.transitionType = .present(.scale)
//        list.presentDelegate?.isDismissGestureEnabled(isEnabled: true)
//        self.present(list, animated: true, completion: nil)
        
        if #available(iOS 10.3, *) {
            if UIApplication.shared.supportsAlternateIcons {
                // backIcon,blueIcon,nil 恢复为默认时设置nil
                UIApplication.shared.setAlternateIconName("blueIcon") { error in
                    print(error ?? "success")
                }
            }
        } else {
            // Fallback on earlier versions
        }
        
        
    }
    
    @IBAction func changeLanguage(_ sender: UISwitch) {
//        sender.isOn ? HeadlineLanguages.switchTo(HeadlineLanguages.Follow): HeadlineLanguages.switchTo(.Chinese)
        if sender.isOn {
            HeadlineTheme.switchTo(HeadlineTheme.night)
        } else {
            HeadlineTheme.switchTo(HeadlineTheme.default)
        }
        
        if #available(iOS 10.3, *) {
            if UIApplication.shared.supportsAlternateIcons {
                // backIcon,blueIcon,nil 恢复为默认时设置nil
                UIApplication.shared.setAlternateIconName(nil) { error in
                    print(error ?? "success")
                }
            }
        } else {
            // Fallback on earlier versions
        }
        
    }
}

